﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PostEffect : MonoBehaviour {

	public Material material;
	
	public DistortionEffect distortionEffect;
	// public BlurEffect blurEffect;
	public GrayEffect grayEffect;


	void Start ()
	{
		distortionEffect = GetComponent<DistortionEffect>();
		grayEffect = GetComponent<GrayEffect>();
		
		//挂到EffectUtil上
		YanhuaMMO.EffectUtil.postEffect = this;
		YanhuaMMO.EffectUtil.postEffectCamera = GetComponent<Camera>();
	}
	
	// void Update () {
	// 	if (Input.GetButton("Fire1"))
	// 	{
	// 		Vector2 pos = new Vector2(Input.mousePosition.x / (float) Screen.width,
	// 			Input.mousePosition.y / (float) Screen.height);
	// 		ShowDistortion(pos);
	// 	}
	// }
	
	public void ShowDistortion(Vector2 center){
		distortionEffect.ShowEffect(center);
	}
	
	public void ShowDistortion(Vector2 center, float waveCount, float waveTotalTime, float maxInRadius, float radius){
		distortionEffect.ShowEffect(center, waveCount, waveTotalTime, maxInRadius, radius);
	}
	
	public void ShowGray(){
		grayEffect.ShowEffect();
	}
	
	// showBlur(){
	// 	this.blurEffect.show(this);
	// },
	//
	
	
	 // private void OnGUI()
	 // {
	 // 	// if(GUILayout.Button("ShowGray", GUILayout.Width(200),GUILayout.Height(100)))
	 // 	// {
	 // 	// 	Debug.Log("ShowGray");
	 // 	// 	ShowGray();
	 // 	// }
	 // 	//
	 // 	// if(GUILayout.Button("End ShowGray", GUILayout.Width(200),GUILayout.Height(100)))
	 // 	// {
	 // 	// 	Debug.Log("End ShowGray");
	 // 	// 	grayEffect.EndEffect();
	 // 	// }
	 // 	
	 // 	//
	 // 	if(GUILayout.Button("ShowDistortion", GUILayout.Width(200),GUILayout.Height(100)))
	 // 	{
	 // 		Debug.Log("ShowDistortion");
	 // 		// ShowDistortion(new Vector2(Screen.currentResolution.width / 2f, Screen.currentResolution.height / 2f));
	 // 		ShowDistortion(new Vector2(0.5f, 0.5f));
	 // 	}
	 // 	
	 // 	if(GUILayout.Button("End ShowDistortion", GUILayout.Width(200),GUILayout.Height(100)))
	 // 	{
	 // 		Debug.Log("End ShowDistortion");
	 // 		distortionEffect.EndEffect();
	 // 	}
	 // }
}
